package org.de.maeyer.statistic;

/**
 * @author Peter De Maeyer
 */
public class ObjectCategory implements Category {

	private final Object value;

	private final long count;

	public ObjectCategory(Object value, long count) {
		this.value = value;
		this.count = count;
	}

	/**
	 * Copy constructor.
	 */
	public ObjectCategory(ObjectCategory category) {
		this(category.value, category.count);
	}
	
	@Override
	public boolean contains(Object value) {
	    if (this.value == null) {
			return value == null;
		}
		return this.value.equals(value);
	}

	@Override
	public Object getValue() {
		return value;
	}

	@Override
	public long getCount() {
		return count;
	}
	
	@Override
	public double getWidth() {
		return 1.;
	}
	
	@Override
	public double getDensity() {
	    return count;
	}

	@Override
	public String toString() {
		return new StringBuilder(50).append(value).append(':').append(count).toString();
	}
}
